package casa.depesos.app.com.view;

import android.content.Context;
import android.util.AttributeSet;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;

import casa.depesos.app.com.it.TextChangeListener;

public class MyTextView extends AppCompatTextView {
    TextChangeListener listener;

    public MyTextView(@NonNull Context context) {
        super(context);
    }

    public MyTextView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyTextView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void setListener(TextChangeListener listener) {
        this.listener = listener;
    }

    public void onTextChange(int index) {
        if (listener != null) {
            listener.onTextChange(getText().toString(), index);
        }
    }
}
